/// @tags: SPFA Graph
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 2e5 + 1;

int n;
bool vis[maxn];
long long s[maxn], d[maxn];
std::vector<int> son[maxn], fa[maxn];

void spfa() {
  std::queue<int> q;
  for (int i = 1; i <= n; ++i) q.push(i), vis[i] = true;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = false;
    long long nd = s[u];
    for (auto i : son[u]) {
      nd += d[i];
    }
    if (nd < d[u]) {
      d[u] = nd;
      for (auto i : fa[u])
        if (!vis[i]) vis[i] = true, q.push(i);
    }
  }
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int r;
    cin >> s[i] >> d[i] >> r;
    for (int j = 1; j <= r; ++j) {
      int item;
      cin >> item;
      son[i].push_back(item);
      fa[item].push_back(i);
    }
  }
  spfa();
  cout << d[1] << endl;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P4042 [AHOI2014 | JSOI2014]骑士游戏.in", "r", stdin);
  freopen("P4042 [AHOI2014 | JSOI2014]骑士游戏.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
